package com.castile.secondkill.response;

/**
 * 全局公共返回
 *
 * @author Hongliang Zhu
 * @create 2023-03-05 20:49
 */
public class CommonResponse {

    /**
     * 如果status=success， 则data内返回前端需要的json数据，如果status=fail，则data里面是统一的错误码格式。
     */
    private Status status;

    /**
     * 返回的数据
     */
    private Object data;

    public static CommonResponse create(Object result) {
        return CommonResponse.create(result, Status.SUCCESS);
    }

    public static CommonResponse create(Object result, Status status) {
        CommonResponse commonReturnType = new CommonResponse();
        commonReturnType.setData(result);
        commonReturnType.setStatus(status);
        return commonReturnType;
    }


    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
